package com.jiuyin.dianjing.ui.fragment.match;


import android.util.Pair;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.jiuyin.dianjing.R;
import com.jiuyin.dianjing.adapter.TabAdapter;
import com.jiuyin.dianjing.ui.fragment.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Description:
 * File: AboutWarFragment.java
 * Author: Administrator
 * Create: 2020/7/9 18:02
 */
public class AboutWarFragment extends BaseFragment {

    @BindView(R.id.tv_title)
    TextView mTitle;

    @BindView(R.id.vp_view_container)
    ViewPager mViewPager;
    @BindView(R.id.tabs)
    TabLayout mTabLayout;
    private TabAdapter mTabAdapter;
    protected final List<Pair<String, Fragment>> mFragments = new ArrayList<>();

    @Override
    public void fetchData() {

    }

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_training_camp;
    }

    @Override
    protected void initData() {
        addFragments();
        initTabLayout();
    }

    @Override
    protected void initView() {
        mTitle.setText(R.string.training_yuezhan);
        showReturnButton();
    }

    protected void addFragments() {
        mFragments.add(Pair.create(getString(R.string.match_game_wangzherongyao), TrainingCampItemFragment.newInstance(R.drawable.bg_yz_wz)));
        mFragments.add(Pair.create(getString(R.string.match_game_yingxionglianmeng), TrainingCampItemFragment.newInstance(R.drawable.bg_yz_yx)));
        mFragments.add(Pair.create(getString(R.string.match_game_hepingjingying), TrainingCampItemFragment.newInstance(R.drawable.bg_yz_hp)));
    }

    protected void initTabLayout() {
        mTabAdapter = new TabAdapter(getFragmentManager(), mFragments);
        mViewPager.setAdapter(mTabAdapter);
        mViewPager.setOffscreenPageLimit(mFragments.size());
        mTabLayout.setupWithViewPager(mViewPager);
    }
}
